package ${basePackage}.cli.command.children;

import ${basePackage}.model.DataModel;
import ${basePackage}.generator.MainGenerator;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import picocli.CommandLine;

import java.util.concurrent.Callable;

/**
* @author tzf
* @description: 生成低代码
* @date: 2024/6/14 15:35
*/
@Slf4j
@CommandLine.Command(name = "generate", description = "生成低代码", mixinStandardHelpOptions = true)
@Data
public class GenerateCommand implements Callable<Integer> {
    <#list modelConfig.models as modelInfo>
        @CommandLine.Option(names = {<#if modelInfo.abbr??>"-${modelInfo.abbr}",</#if><#if modelInfo.fieldName??>"--${modelInfo.fieldName}"</#if>}, arity = "0..1", <#if modelInfo.description??>description = "${modelInfo.description}"</#if>, interactive = true,echo=true)
        private ${modelInfo.type} ${modelInfo.fieldName} <#if modelInfo.defaultValue??>=${modelInfo.defaultValue?c}</#if>;
    </#list>

    @Override
    public Integer call() throws Exception {
    DataModel dataModel = DataModel.builder().build();
    BeanUtil.copyProperties(this, dataModel);
    log.info("配置信息=>{}", dataModel.toString());
    MainGenerator.doGenerate(dataModel);
    return 0;
    }
    }
